package com.itcast.n1_内存调优;

/**
 * @program: jvm
 * @description:
 * @author: flyduck
 * @create: 2024-10-16 16:41
 **/
public class Test10_内存遗漏问题3_new创建的线程没有调用threadlocal的remove方法不会导致内存泄漏 {
    public static ThreadLocal<Object> threadLocal = new ThreadLocal<>();

    public static void main(String[] args) throws InterruptedException {
        while (true) {
            new Thread(() -> {
                threadLocal.set(new byte[1024 * 1024 * 10]);
            }).start();
            Thread.sleep(10);
        }
    }
}
